    function addNodes(srcObjName,desObjName)
    {
        srcObj=document.getElementById(srcObjName);
        desObj=document.getElementById(desObjName);  
        var srcLen=srcObj.length;
        var over = false;
        for(var i=0;i<srcLen;i++)
        {
            var srcOpt=srcObj.options[i];
            if(srcOpt.selected){
                if(!over){
                    var desLen=desObj.length;
                    for(var j=0;j<desLen;j++){
                        var tempId=desObj.options[j].value;
                        if('none'==tempId){
                            desObj.remove(j);
                            break;
                        }
                    }
                    over=true;
                }
                var desLen=desObj.length;
                var isContinue=false;
                for(var j=0;j<desLen;j++){
                    var tempId=desObj.options[j].value;
                    if(srcOpt.value==tempId){
                        isContinue=true;
                        continue;
                    }
                }
                if(isContinue==true) continue;
                desObj.options.add(new Option(srcOpt.text,srcOpt.value));
            }
        }
    }
    function removeNodes(remObjName)
    {
        remObj=document.getElementById(remObjName);
        var len=remObj.length;
        for(var i=len-1;i>=0;i--){
            if(remObj.options[i].selected){
                remObj.removeChild(remObj.options[i]);
            }
        }
    }

    function moveNodes(srcObjName,destObjName) {
        srcObj=document.getElementById(srcObjName);
        destObj=document.getElementById(destObjName);
        addNodes(srcObjName,destObjName);
        removeNodes(srcObjName);
    }

    function selectAll(selObj)
    {
        var len=selObj.length;
        for(var i=0;i<len;i++){                
            selObj.options[i].selected=true;
        }
    }
    function  moveTop(objName){ 
    	obj=document.getElementById(objName);
			var  opts = []; 
			for(var i =obj.options.length -1 ; i >= 0; i--){
				if(obj.options[i].selected){
					opts.push(obj.options[i]);
					obj.remove(i);
				}
			}
			var index = 0 ;
			for(var t = opts.length-1 ; t>=0 ; t--){
				var opt = new Option(opts[t].text,opts[t].value);
				opt.selected = true;
				obj.options.add(opt, index++);
			}
		} 
	function  moveBottom(objName) {
		obj=document.getElementById(objName);
		var  opts = [];
		for(var i =obj.options.length -1 ; i >= 0; i--){
			if(obj.options[i].selected){
				opts.push(obj.options[i]);
				obj.remove(i);
			}
		}
		for(var t = opts.length-1 ; t>=0 ; t--){
			var opt = new Option(opts[t].text,opts[t].value);
			opt.selected = true;
			obj.options.add(opt);
		}
	} 
	function moveUp(objName){
		obj=document.getElementById(objName);
		for(var i=1; i < obj.length; i++){
			if(obj.options[i].selected){
				if(!obj.options.item(i-1).selected){
					var selText = obj.options[i].text;
					var selValue = obj.options[i].value;
					obj.options[i].text = obj.options[i-1].text;
					obj.options[i].value = obj.options[i-1].value;
					obj.options[i].selected = false;
					obj.options[i-1].text = selText;
					obj.options[i-1].value = selValue;
					obj.options[i-1].selected=true;
				}
			}
		}
	}
	function moveDown(objName){
		obj=document.getElementById(objName);
		for(var i = obj.length -2 ; i >= 0; i--){
			if(obj.options[i].selected){
				if(!obj.options[i+1].selected){
					var selText = obj.options[i].text;
		            var selValue = obj.options[i].value;
				    obj.options[i].text = obj.options[i+1].text;
				    obj.options[i].value = obj.options[i+1].value;
				    obj.options[i].selected = false;
				    obj.options[i+1].text = selText;
				    obj.options[i+1].value = selValue;
				    obj.options[i+1].selected=true;
				}
			}
		}
	}
	function moveGroupNodesLeft(srcObjName,destObjName) {
		srcObj=document.getElementById(srcObjName);
        destObj=document.getElementById(destObjName);
        remObj=document.getElementById(srcObjName);
        var arr=remObj.getElementsByTagName("option");
        
        for(var i=arr.length-1;i>=0;i--)
        {
            if(arr[i].selected)
            {
                var node = document.createElement("option");
                node.setAttribute("value", arr[i].getAttribute("value"));
                node.appendChild(document.createTextNode(arr[i].text));
                destObj.appendChild(node);
            }
        }
        for(var i=arr.length-1;i>=0;i--)
        {
            if(arr[i].selected)
            {
                var objGroup=document.getElementById("optgroup_"+arr[i].value.split("#")[0]);
                objGroup.removeChild(arr[i]);
               
            }
        }
    }
    function moveGroupNodesRight(srcObjName,destObjName){
        srcObj=document.getElementById(srcObjName);
        destObj=document.getElementById(destObjName);
        remObj=document.getElementById(srcObjName);

        var nlist=remObj.getElementsByTagName("option");

        for(var i=nlist.length-1;i>=0;i--)
        {
            if(nlist[i].selected)
            {
                var group=document.getElementById("optgroup_"+nlist[i].getAttribute("value").split("#")[0]);
                var node = document.createElement("option");
                node.setAttribute("value", nlist[i].getAttribute("value"));
                node.appendChild(document.createTextNode(nlist[i].text));
                group.appendChild(node);
                remObj.removeChild(nlist[i]);
            }
        }
    }
    function selectGroupAll(selObj)
    {
        var len=selObj.length;
        for(var i=0;i<len;i++){
        	selObj.options[i].value = selObj.options[i].value.split("#")[1];
            selObj.options[i].selected=true;
        }
    }